﻿using System;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.Reflection;

public partial class System_Controls_FieldTemplates_DateTime : System.Web.UI.UserControl
{
    public string Title
    {
        get { return lb_Title.Text; }
        set { lb_Title.Text = value; }
    }
    public DateTime Value
    {
        get
        {
            return Convert.ToDateTime(tb_Value.Text + " " + ddl_h.SelectedValue + ":" + ddl_m.SelectedValue + ":00");
        }
        set
        {
            //LoadDDLHour();
            //LoadDDLMinute();
            tb_Value.Text = value.ToShortDateString();
            ddl_h.SelectedValue = value.Hour.ToString("00");
            ddl_m.SelectedValue = value.Minute.ToString("00");
        }
    }

    protected void Page_Init(object sender, EventArgs e)
    {
        LoadDDLHour();
        LoadDDLMinute();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    void LoadDDLHour()
    {
        if (ddl_h.Items.Count == 0) 
        { 
            for (int i = 0; i <= 23; i++)
            {
                ListItem myListItem = new ListItem(i.ToString("00"), i.ToString("00"));
                ddl_h.Items.Add(myListItem);
            }
        }
    }
    void LoadDDLMinute()
    {
        if (ddl_m.Items.Count == 0)
        { 
            for (int i = 0; i <= 59; i++)
            {
                ListItem myListItem = new ListItem(i.ToString("00"), i.ToString("00"));
                ddl_m.Items.Add(myListItem);
            }
        }
    }
}